#!/bin/sh
mount -o remount,rw /
# Get Application Install Directory
if (cat /etc/palm/luna.conf | grep -i "/media/cryptofs/apps") ; then
	INSTDIR=/media/cryptofs/apps
else
	INSTDIR=/var
    echo "can't install on this ROM"
    exit 0
fi

PATCHDIR=$INSTDIR/usr/palm/applications/com.youjf.justinput/
mkdir -p $PATCHDIR

rm -rf /usr/palm/frameworks/mojo/justinput/
rm -f /usr/lib/luna/java/justinput.jar
rm -f /usr/share/dbus-1/system-services/com.youjf.jisrv.service
rm -f /etc/event.d/com.youjf.com.justinput
rm -f /usr/palm/frameworks/mojo/mojo.js.old
rm -rf /var/home/root/.justinput/

if [ -f "/usr/palm/frameworks/mojo/builtins/palmInitFramework338.js" ]; then
    rm -f /usr/palm/frameworks/mojo/builtins/palmInitFramework338.js.jeffery
    mv -f $PATCHDIR/palmInitFramework338.ori.js /usr/palm/frameworks/mojo/builtins/palmInitFramework338.js
fi

if [ -f "/usr/palm/frameworks/mojo/builtins/palmInitFramework347.js" ]; then
    rm -f /usr/palm/frameworks/mojo/builtins/palmInitFramework347.js.jeffery
    mv -f $PATCHDIR/palmInitFramework347.ori.js /usr/palm/frameworks/mojo/builtins/palmInitFramework347.js
fi

HackFile="/usr/palm/frameworks/mojo/mojo.js"
StartLine=`sed -n "/justinput hack start/=" ${HackFile}`
EndLine=`sed -n "/justinput hack end/=" ${HackFile}`
if ((test ${StartLine} > 0) && (test ${EndLine} > 0)) then
    sed "${StartLine},${EndLine}d" "${HackFile}" > ${HackFile}.tmp
    mv -f ${HackFile}.tmp ${HackFile}
fi

rm -rf $PATCHDIR

killall -9 java
exit 0
